﻿#r @"C:\Users\Phil\Documents\Visual Studio 10\Projects\FSharp-PowerPack-4.0-Beta1\FSharp.PowerPack.dll"
#r @"C:\Users\Phil\Documents\Visual Studio 10\Projects\FSharpChess\FsharpCode\FsharpCode\..\..\bin\Debug\FsharpChessCode.dll"
#r @"C:\Users\Phil\Documents\Visual Studio 10\Projects\Xunit\xunit-1.5-ctp1\xunit.dll"
#r @"C:\Users\Phil\Documents\Visual Studio 10\Projects\FSharpChess\FsharpCode\FsharpChessTests\bin\Debug\FsharpChessTests.dll"
open FSharpChess
let setup_pos1() =
    Funcs.New("")
    let FEN1 = "1k1r4/1pp4p/p7/4p3/8/P5P1/1PP4P/2K1R3 w - - 0 1"
    Funcs.SetBoardPosition(FEN1)
let setup_pos2() =
    Funcs.New("")
    let FEN1 = "1k1r3q/1ppn3p/p4b2/4p3/8/P2N2P1/1PP1R1BP/2K1Q3 w - - 0 1"
    Funcs.SetBoardPosition(FEN1)
let setup_pos13() =
    Funcs.New("")
    let FEN1 = "k1r5/3B4/8/8/8/8/8/7K w - - 0 1"
    Funcs.SetBoardPosition(FEN1)

Psn_tests.setup_pos13()
Funcs.gm.SetMaterialCount()
let mv = Funcs.gm.CreateMove(Standard, 2, 51, 42, -1, 0)
let cond = not (Move_check.move_is_check mv Funcs.gm)
let pc = Funcs.gm.Pcs.[mv.mvPiece]
let psn = Funcs.gm
let kingisW = not psn.PlayerToPlay.prIsWhite
let kingid = if kingisW then 4 else 20
let kingpc = psn.Pcs.[kingid]
let kingsq = kingpc.SquareOrd
let rec getRincheck r rl =
    match r with
        |[] -> if rl=[] then false else getRincheck rl.Head rl.Tail
        | r ->  
            let cord = r.Head 
            if cord = kingsq then
                true
            elif psn.Sqs.[cord] = -1 then
                getRincheck r.Tail rl 
            else
                if rl=[] then false else getRincheck rl.Head rl.Tail
let ans = getRincheck Ref.raysB.[mv.To].Head Ref.raysB.[mv.To].Tail
let rays = Ref.raysB.[mv.To]